package com.itheima.loger;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyLog {
    @Pointcut("execution(* com.itheima.service.impl.*.*(..))")
    public void pt(){};
    @Around("pt()")
    public Object printLog(ProceedingJoinPoint joinPoint) throws Throwable {
        Object proceed=null;
        try {
            System.out.println("方法之前前的方法");
            proceed=joinPoint.proceed();
            System.out.println("方法执行之后执行的方法");
        } catch (Throwable throwable) {
            System.out.println("出现了异常");
            throw throwable;
        } finally {
            System.out.println("最终通知......");
        }
        return proceed;
    }
}
